//
//  CLPushWindow.m
//  chanlin
//
//  Created by Ryan on 14-12-23.
//  Copyright (c) 2014年 chanlin. All rights reserved.
//

#import "CLPushWindow.h"
#import "CLSlidersViewController.h"
#import "CLDocViewController.h"
#import "CLTopicViewController.h"
#import "CLVideoViewController.h"
#import "CLSubViewController.h"
#import "ClEntityHead.h"
#import "CLGloble.h"
@implementation CLPushWindow

+ (CLPushWindow *)createPuhsWindowWithType:(int)type docId:(NSString *)did animation:(BOOL)animation{
    CLPushWindow *push=[[CLPushWindow alloc] init];
    [CLGloble sharedInstance].pushWindow=push;
    push.windowLevel=UIWindowLevelStatusBar;
    
    
    push.panGesture=[[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)];
    [push addGestureRecognizer:push.panGesture];
    push.panGesture.delegate=push;

    
    if(type==CLList_sliders){
        CLSlidersViewController *slider=[CLSlidersViewController new];
        slider.itemId=did;
        push.rootViewController=slider;
        
    }else if(type==CLList_doc){
        CLDocViewController *doc=[CLDocViewController new];
        doc.itemId=did;
        push.rootViewController=doc;

           }else if(type==CLList_topic){
        CLTopicViewController *topic=[CLTopicViewController new];
        topic.itemId=did;
        push.rootViewController=topic;
    }else if(type==CLList_video){
        CLVideoViewController *video=[CLVideoViewController new];
        video.itemId=did;
        push.rootViewController=video;

            }else if(type==CLList_sub){
        CLSubViewController *sub=[CLSubViewController new];
        sub.itemId=did;
      
        push.rootViewController=sub;
            }
    if(animation){
        push.frame=CGRectMake(0, 0, GlobleWidth, GlobleHeight);
        [push makeKeyAndVisible];
        [UIView animateWithDuration:0.4 animations:^{
            push.frame=CGRectMake(0, 0, GlobleWidth, GlobleHeight);

        }];
    }else{
        push.frame=CGRectMake(0, 0, GlobleWidth, GlobleHeight);
        [push makeKeyAndVisible];
    }
    
    return push;

    
}



@end
